#ifndef PSD_XFER_H
#define PSD_XFER_H

#include <pthread.h>

#include "psd_session.h"
#include "psd_conn.h"

typedef struct xfer_args_t {
	psdSess *sess;

	psdConn *sink;
	psdConn *src;

	LIST_ENTRY(xfer_args_t) xfer_entries;

	int pipes[2];

	uint64_t xfer_amt;
	
	void *buf;
	int bufsize;

	int parent_fd;

	void *io_private;

	pthread_cond_t cond;
	pthread_cond_t sink_cond;
	pthread_mutex_t lock;
	pthread_mutex_t sink_lock;

	pthread_cond_t buf_cond;
	pthread_mutex_t buf_lock;
} psdXferArgs;

psdXferArgs *psd_alloc_xfer_args(void);
psdXferArgs *psd_alloc_xfer_args_set(psdSess *sess, psdConn *src, psdConn *sink, int bufsize);
void psd_free_xfer_args(psdXferArgs *args);
#endif
